package model

import (
	"github.com/fantomo/go-iching/utils/mysql"
	"gorm.io/gorm"
)

// Divination 占卜
type Divination struct {
	ID               int    `gorm:"column:id;type:int;" json:"id" `
	Name             string `gorm:"column:name;type:varchar(255);" json:"name"`
	SortName         string `gorm:"column:sort_name;type:varchar(255);" json:"sortName"`
	DivinatorySymbol string `gorm:"column:divinatory_symbol;type:varchar(255);" json:"divinatorySymbol"`
	JiXiong          string `gorm:"column:jixiong;type:varchar(255);" json:"jiXiong"`
	XiangSaid        string `gorm:"column:xiang_said;type:varchar(255);" json:"xiangSaid"`
	Cause            string `gorm:"column:cause;type:varchar(255);" json:"cause"`
	Business         string `gorm:"column:business;type:varchar(255);" json:"business"`
	Reputation       string `gorm:"column:reputation;type:varchar(255);" json:"reputation"`
	GoOut            string `gorm:"column:go_out;type:varchar(255);" json:"goOut"`
	Marriage         string `gorm:"column:marriage;type:varchar(255);" json:"marriage"`
	Decision         string `gorm:"column:decision;type:tinyint;default:0" json:"decision"`
}

// TableName 表名
func (divination *Divination) TableName() string {
	return "divination"
}

// GetDivinationDetailBySymbol 通过卦象获取占卜详情
func GetDivinationDetailBySymbol(symbol string) (Divination, *gorm.DB) {
	var divination Divination
	return divination, mysql.DB.Where("divinatory_symbol = ?", symbol).Find(&divination)
}

// GetAll 通过卦象获取占卜详情
func GetAll() ([]Divination, *gorm.DB) {
	var divination[] Divination
	return divination, mysql.DB.Find(&divination)
}
